New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@thi.ng/shader-ast-glsl

Package Overview
Dependencies
Maintainers
0
Versions
248
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/shader-ast-glsl

Customizable GLSL codegen for @thi.ng/shader-ast

  • 0.4.146
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
212
decreased by-27.15%
Maintainers
0
Weekly downloads
 
Created
Source

@thi.ng/shader-ast-glsl

npm version npm downloads Mastodon Follow

[!NOTE] This is one of 200 standalone projects, maintained as part of the @thi.ng/umbrella monorepo and anti-framework.

🚀 Please help me to work full-time on these projects by sponsoring me on GitHub. Thank you! ❤️

About

GLSL code generator for @thi.ng/shader-ast. Currently supports GLSL ES 1.00 (WebGL) & GLSL ES 3.00 (WebGL 2).

This package is also used for shader assembly by @thi.ng/webgl.

Status

STABLE - used in production

Search or submit any issues for this package

Installation

yarn add @thi.ng/shader-ast-glsl

ESM import:

import * as glsl from "@thi.ng/shader-ast-glsl";

Browser ESM import:

<script type="module" src="https://esm.run/@thi.ng/shader-ast-glsl"></script>

JSDelivr documentation

For Node.js REPL:

const glsl = await import("@thi.ng/shader-ast-glsl");

Package sizes (brotli'd, pre-treeshake): ESM: 1.30 KB

Dependencies

Note: @thi.ng/api is in most cases a type-only import (not used at runtime)

Usage examples

Six projects in this repo's /examples directory are using this package:

ScreenshotDescriptionLive demoSource
2D canvas shader emulationDemoSource
HOF shader procedural noise function compositionDemoSource
WebGL & JS canvas2D raymarch shader cross-compilationDemoSource
WebGL & JS canvas 2D SDFDemoSource
WebGL & Canvas2D textured tunnel shaderDemoSource
Entity Component System w/ 100k 3D particlesDemoSource

API

Generated API docs

Basic GLSL code generation

import { assign, defMain, output, program, uniform, vec4 } from "@thi.ng/shader-ast";
import { GLSLVersion, targetGLSL } from "@thi.ng/shader-ast-glsl";

const glsl = targetGLSL({
    // target WebGL2
    version: GLSLVersion.GLSL_300,
    // emit #version pragma
    versionPragma: true,
    // fragment shader
    type: "fs",
    // custom prelude
    prelude: `
// custom GLSL source string injection, e.g.
#define PI 3.1415926`
});

let color: Vec3Symbol;
let fragColor: Vec4Symbol;

glsl(
    program([
        color = uniform("vec3", "color"),
        fragColor = output("vec4", "fragColor", { loc: 0 }),
        defMain(()=> [
            assign(fragColor, vec4(color, 1))
        ])
    ])
)
#version 300 es

// custom GLSL source string injection, e.g.
#define PI 3.1415926
uniform vec3 color;
layout(location=0) out vec4 fragColor;
void main() {
fragColor = vec4(color, 1.0);
}

Authors

If this project contributes to an academic publication, please cite it as:

@misc{thing-shader-ast-glsl,
  title = "@thi.ng/shader-ast-glsl",
  author = "Karsten Schmidt",
  note = "https://thi.ng/shader-ast-glsl",
  year = 2019
}

License

© 2019 - 2024 Karsten Schmidt // Apache License 2.0

Keywords

FAQs

Package last updated on 27 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc